<?php
namespace app\api\controller;
use think\Controller;

class Index extends Controller {
    public function __construct(){
        parent::__construct();
        header('Access-Control-Allow-Origin:*');
        header('Access-Control-Allow-Methods:GET');
        header('Access-Control-Allow-Methods:POST');
        header('Access-Control-Allow-Headers:x-requested-with,content-type');
    }

    public function index(){
        
        $filename = dirname(__FILE__) . "/api.json";//文件相对路径

        $json_string = file_get_contents($filename);//读取json内容

        $this->assign("api",$json_string);
        //$this->display("index.html");
        return view('index');
    }
    public function second(){
        $filename=dirname(__FILE__)."/secondapi.json";
        $json_string=file_get_contents($filename);
        $this->assign("api",$json_string);
        $this->display();
    }

}